package com.lamp.main;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.LinearLayout;

import com.lamp.tabgroups.FeedGroup;

public class HomescreenActivity extends Activity implements OnTouchListener,
		OnClickListener {
	LinearLayout l1;
	Button b1;

	LinearLayout l2;
	Button b2;

	LinearLayout l3;
	Button b3;

	LinearLayout l4;
	Button b4;

	LinearLayout l6;
	Button b6;

	LinearLayout l7;
	Button b7;

	LinearLayout l8;
	Button b8;

	LinearLayout l9;
	Button b9;

	Button checkin_btn;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.homescreen);
		l1 = (LinearLayout) findViewById(R.id.l1);
		b1 = (Button) findViewById(R.id.b1);
		b1.setOnTouchListener(this);
		b1.setOnClickListener(this);

		l2 = (LinearLayout) findViewById(R.id.l2);
		b2 = (Button) findViewById(R.id.b2);
		b2.setOnTouchListener(this);
		b2.setOnClickListener(this);

		l3 = (LinearLayout) findViewById(R.id.l3);
		b3 = (Button) findViewById(R.id.b3);
		b3.setOnTouchListener(this);
		b3.setOnClickListener(this);

		l4 = (LinearLayout) findViewById(R.id.l4);
		b4 = (Button) findViewById(R.id.b4);
		b4.setOnTouchListener(this);
		b4.setOnClickListener(this);

		l6 = (LinearLayout) findViewById(R.id.l6);
		b6 = (Button) findViewById(R.id.b6);
		b6.setOnTouchListener(this);
		b6.setOnClickListener(this);

		l7 = (LinearLayout) findViewById(R.id.l7);
		b7 = (Button) findViewById(R.id.b7);
		b7.setOnTouchListener(this);
		b7.setOnClickListener(this);

		l8 = (LinearLayout) findViewById(R.id.l8);
		b8 = (Button) findViewById(R.id.b8);
		b8.setOnTouchListener(this);
		b8.setOnClickListener(this);

		l9 = (LinearLayout) findViewById(R.id.l9);
		b9 = (Button) findViewById(R.id.b9);
		b9.setOnTouchListener(this);
		b9.setOnClickListener(this);

		checkin_btn = (Button) findViewById(R.id.checkin_btn);
		checkin_btn.setOnClickListener(this);
	}

	public boolean onTouch(View v, MotionEvent e) {
		if (e.getAction() == MotionEvent.ACTION_DOWN) {
			switch (v.getId()) {
			case R.id.b1:
				l1.setBackgroundResource(R.drawable.defualt_main_btn_c);
				b1.setBackgroundResource(R.drawable.whowhere_btn_i);
				b1.setTextColor(LoginActivity.resource.getColor(R.color.orange));
				break;
			case R.id.b2:
				l2.setBackgroundResource(R.drawable.defualt_main_btn_c);
				b2.setBackgroundResource(R.drawable.account_btn_i);
				b2.setTextColor(LoginActivity.resource.getColor(R.color.orange));
				break;

			case R.id.b3:
				l3.setBackgroundResource(R.drawable.defualt_main_btn_c);
				b3.setBackgroundResource(R.drawable.nearby_btn_i);
				b3.setTextColor(LoginActivity.resource.getColor(R.color.orange));
				break;

			case R.id.b4:
				l4.setBackgroundResource(R.drawable.defualt_main_btn_c);
				b4.setBackgroundResource(R.drawable.message_btn_i);
				b4.setTextColor(LoginActivity.resource.getColor(R.color.orange));
				break;

			case R.id.b6:
				l6.setBackgroundResource(R.drawable.defualt_main_btn_c);
				b6.setBackgroundResource(R.drawable.deals_btn_i);
				b6.setTextColor(LoginActivity.resource.getColor(R.color.orange));
				break;

			case R.id.b7:
				l7.setBackgroundResource(R.drawable.defualt_main_btn_c);
				b7.setBackgroundResource(R.drawable.reward_btn_i);
				b7.setTextColor(LoginActivity.resource.getColor(R.color.orange));
				break;

			case R.id.b8:
				l8.setBackgroundResource(R.drawable.defualt_main_btn_c);
				b8.setBackgroundResource(R.drawable.iwant_btn_i);
				b8.setTextColor(LoginActivity.resource.getColor(R.color.orange));
				break;

			case R.id.b9:
				l9.setBackgroundResource(R.drawable.defualt_main_btn_c);
				b9.setBackgroundResource(R.drawable.friends_btn_i);
				b9.setTextColor(LoginActivity.resource.getColor(R.color.orange));
				break;
			default:
				break;
			}

		} else if (e.getAction() == MotionEvent.ACTION_UP) {
			switch (v.getId()) {
			case R.id.b1:
				l1.setBackgroundResource(R.drawable.defualt_main_btn);
				b1.setBackgroundResource(R.drawable.whowhere_btn);
				b1.setTextColor(Color.WHITE);
				break;
			case R.id.b2:
				l2.setBackgroundResource(R.drawable.defualt_main_btn);
				b2.setBackgroundResource(R.drawable.account_btn);
				b2.setTextColor(Color.WHITE);
				break;

			case R.id.b3:
				l3.setBackgroundResource(R.drawable.defualt_main_btn);
				b3.setBackgroundResource(R.drawable.nearby_btn);
				b3.setTextColor(Color.WHITE);
				break;

			case R.id.b4:
				l4.setBackgroundResource(R.drawable.defualt_main_btn);
				b4.setBackgroundResource(R.drawable.message_btn);
				b4.setTextColor(Color.WHITE);
				break;

			case R.id.b6:
				l6.setBackgroundResource(R.drawable.defualt_main_btn);
				b6.setBackgroundResource(R.drawable.deals_btn);
				b6.setTextColor(Color.WHITE);
				break;

			case R.id.b7:
				l7.setBackgroundResource(R.drawable.defualt_main_btn);
				b7.setBackgroundResource(R.drawable.reward_btn);
				b7.setTextColor(Color.WHITE);
				break;

			case R.id.b8:
				l8.setBackgroundResource(R.drawable.defualt_main_btn);
				b8.setBackgroundResource(R.drawable.iwant_btn);
				b8.setTextColor(Color.WHITE);
				break;

			case R.id.b9:
				l9.setBackgroundResource(R.drawable.defualt_main_btn);
				b9.setBackgroundResource(R.drawable.friends_btn);
				b9.setTextColor(Color.WHITE);
				break;
			default:
				break;
			}

		}
		return false;
	}

	@Override
	public void onClick(View v) {
		Intent intent;
		switch (v.getId()) {
		case R.id.b1:
			// Feed
			break;
		case R.id.b2:
			intent = new Intent(HomescreenActivity.this, MineActivity.class);
			FeedGroup.group.goTo(intent);
			break;

		case R.id.b3:
			// Nearby
			break;

		case R.id.b4:
			// Message
			break;

		case R.id.b6:
			// Deals
			break;

		case R.id.b7:
			// Reward
			break;

		case R.id.b8:
			// I Want
			break;

		case R.id.b9:
			// Friens
			break;
		case R.id.checkin_btn:
			intent = new Intent(HomescreenActivity.this, CheckInActivity.class);
			((TabBarActivity) getParent().getParent()).visibleTabWedgit();
			FeedGroup.group.goTo(intent);
			break;
		default:
			break;
		}
	}
}
